package gupao.concurrency.simpleweb;

import com.google.gson.Gson;

import java.util.HashMap;
import java.util.Map;

public class Resp {

    public static String successResp(Object data){
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("code", "20000");
        dataMap.put("data", data);
        return new Gson().toJson(dataMap);
    }

    public static String failResp(String error){
        Map<String, Object> dataMap = new HashMap<>();
        dataMap.put("code", "-1");
        dataMap.put("msg", error);
        return new Gson().toJson(dataMap);
    }
}
